home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************
- *
- * PARAMS.C
- *
- **************************************************************/
-
- #include <acs.h>
- #include <acsplus.h>
- #include <stdlib.h>
- #include <string.h>
- #include <tos.h>
- #include <messages.pif>
- #include <acs_plus.pif>
- #include <graphics.pif>
- #include <diskfile.pif>
-
- static int cdecl note(PARMBLK *parmblk) ;
-
- #include "params.pif"
- #include "params.h"
- #include "params.ah"
-
- #define TITLE_FIELD_LENGTH 40 /** length of title field in params object **/
-
- static char default_path[pathname_length] ; /** for MIDI_PRT.PAR **/
-
- /*** paths where to search for files, for all instances together ***/
- static char savepath[pathname_length] ;
- static char loadpath[pathname_length] ;
- static char savepathname[pathname_length] ;
- static char loadpathname[pathname_length] ;
-
- /*** array for addressing menu entries in program loops, ***/
- /*** FONT_i are not defined in sequence by ACS ! ***/
-
- static char FONT_INDEX[MAX_FONTS] =
- {
- FONT_0 , FONT_1 , FONT_2 , FONT_3 , FONT_4 , FONT_5 , FONT_6 , FONT_7 , FONT_8 , FONT_9 ,
- FONT_10 , FONT_11 , FONT_12 , FONT_13 , FONT_14 , FONT_15 , FONT_16 , FONT_17 , FONT_18 , FONT_19 ,
- FONT_20 , FONT_21 , FONT_22 , FONT_23 , FONT_24 , FONT_25 , FONT_26 , FONT_27 , FONT_28 , FONT_29 ,
- FONT_30 , FONT_31 , FONT_32 , FONT_33 , FONT_34 , FONT_35 , FONT_36 , FONT_37 , FONT_38 , FONT_39 ,
- FONT_40 , FONT_41 , FONT_42 , FONT_43 , FONT_44 , FONT_45 , FONT_46 , FONT_47 , FONT_48 , FONT_49 ,
- FONT_50 , FONT_51 , FONT_52 , FONT_53 , FONT_54 , FONT_55 , FONT_56 , FONT_57 , FONT_58 , FONT_59 ,
- FONT_60 , FONT_61 , FONT_62 , FONT_63 , FONT_64 , FONT_65 , FONT_66 , FONT_67 , FONT_68 , FONT_69 ,
- FONT_70 , FONT_71 , FONT_72 , FONT_73 , FONT_74 , FONT_75 , FONT_76 , FONT_77 , FONT_78 , FONT_79 ,
- FONT_80 , FONT_81 , FONT_82 , FONT_83 , FONT_84 , FONT_85 , FONT_86 , FONT_87 , FONT_88 , FONT_89 ,
- FONT_90 , FONT_91 , FONT_92 , FONT_93 , FONT_94 , FONT_95 , FONT_96 , FONT_97 , FONT_98 , FONT_99 ,
- FONT_100, FONT_101, FONT_102, FONT_103, FONT_104, FONT_105, FONT_106, FONT_107, FONT_108, FONT_109,
- FONT_110, FONT_111, FONT_112, FONT_113, FONT_114, FONT_115, FONT_116, FONT_117, FONT_118, FONT_119,
- FONT_120, FONT_121, FONT_122, FONT_123, FONT_124, FONT_125, FONT_126, FONT_127
- } ;
-
-
-
- typedef struct
- {
- /*** headline ***/
- char title[80] ;
-
- /*** text parameters ***/
- int font_id, effect ;
-
- /*** borders ***/
- char left_border, right_border, lower_border, upper_border ;
-
- /*** y-distances ***/
- char system_distance, track_distance, note_distance ;
-
- /*** bar parameters ***/
- char bars_per_system, bar_length, sub_bars ;
-
- /*** vertical parameters ***/
- int back_style[12], back_color[12], hor_lines, mode ;
-
- /*** note parameters ***/
- int style[12], color[12], type ;
- char height, dynamic ;
- }
- PARAMS_FILE ;
-
-
- /************* OBJECT DATA PROTOTYPE BEGIN ***********************/
-
- /*** show note style or show background style ? ***/
-
- typedef enum {SH_NOTE, SH_BACKGROUND} SHOW ;
-
-
- typedef struct
- {
- char path[pathname_length] ;
- SHOW show ;
- int style[12], color[12], index, front ;
- int back_style[12], back_color[12], back_index ;
- int handle ;
- int effect ;
- int font_id ;
- FONT_INFO *font_info ; /* info about available GDOS fonts */
- int number_fonts ; /* number of elements in font_info[] */
- Awindow *font_wi ; /* pointer to font window */
- Awindow *params_wi ; /* pointer to the parameters window */
- }
- PARAMS ;
-
- /************* OBJECT DATA PROTOTYPE END *************************/
-
-
- /*****************/
- static void keys /*
- ******************/
- (
- Awindow *wi, /* input: parameters window */
- int kstate, /* input: see ACS manual */
- int key /* input: ASCII code and scan code */
- )
- {
- if (set_timer(wi) == -1) Awi_sendall(REDRAW, wi) ;
-
- /*** forward event to ACS for further treatment (e.g. by the desktop) ***/
- Awi_keys(wi, kstate, key) ;
- }
-
- /**********************************************/
- static int cdecl background(PARMBLK *parmblk) /*
- ***********************************************/
- {
- PARAMS *p = (PARAMS *)parmblk->pb_parm ;
- int points[4], clipping_points[4] ;
-
- /*** calculate border points for clipping rectangle, clipping = on ***/
- clipping_points[0] = parmblk->pb_xc ;
- clipping_points[1] = parmblk->pb_yc ;
- clipping_points[2] = clipping_points[0] + parmblk->pb_wc - 1 ;
- clipping_points[3] = clipping_points[1] + parmblk->pb_hc - 1 ;
- vs_clip(p->handle, TRUE, clipping_points) ;
-
- /*** fit points to userdef object size and location ***/
- points[0] = parmblk->pb_x ;
- points[1] = parmblk->pb_y ;
- points[2] = points[0] + parmblk->pb_w - 1 ;
- points[3] = points[1] + parmblk->pb_h - 1 ;
-
- /*** set drawing styles ***/
- if (p->back_style[p->back_index] == IP_HOLLOW)
- vsf_interior(p->handle, FIS_HOLLOW) ;
- else vsf_interior(p->handle, FIS_PATTERN) ;
- vsf_style(p->handle, p->back_style[p->back_index]) ;
- vsf_color(p->handle, p->back_color[p->back_index]) ;
- vsl_color(p->handle, p->back_color[p->back_index]) ;
-
- /*** draw background field ***/
- vr_recfl(p->handle, points) ;
- if (p->back_style[p->back_index] == IP_HOLLOW)
- {
- vsl_width(p->handle, 3) ;
- points[1] = points[3] = (points[1] + points[3]) >> 1 ;
- v_pline(p->handle, 2, points) ;
- vsl_width(p->handle, 1) ;
- }
-
- /*** workaround ???? ***/
- vsf_color(p->handle, BLACK); vsl_color(p->handle, BLACK) ;
-
- /*** clipping = off ***/
- vs_clip(p->handle, FALSE, clipping_points) ;
- return(parmblk->pb_currstate) ;
- }
-
- /**********************************************/
- static int cdecl color_draw(PARMBLK *parmblk) /*
- ***********************************************/
- {
- PARAMS *p = (PARAMS *)parmblk->pb_parm ;
- int points[4], clipping_points[4], i ;
- int number_colors = ncolors ;
- float dx ;
-
- if (number_colors > 16) number_colors = 16 ;
- dx = ((float)parmblk->pb_w) / number_colors ;
-
- /*** calculate border points for clipping rectangle, clipping = on ***/
- clipping_points[0] = parmblk->pb_xc ;
- clipping_points[1] = parmblk->pb_yc ;
- clipping_points[2] = clipping_points[0] + parmblk->pb_wc - 1 ;
- clipping_points[3] = clipping_points[1] + parmblk->pb_hc - 1 ;
- vs_clip(p->handle, TRUE, clipping_points) ;
-
- /*** fit points to userdef object size and location ***/
- points[1] = parmblk->pb_y ;
- points[3] = parmblk->pb_y + parmblk->pb_h - 1 ;
-
- /*** set drawing styles ***/
- vsf_interior(p->handle, FIS_SOLID) ;
-
- /*** draw color fields ***/
- for ( i = 0 ; i < number_colors ; i++ )
- {
- points[0] = parmblk->pb_x + (dx * i) ;
- points[2] = points[0] + dx ;
- vsf_color(p->handle, i) ;
- v_bar(p->handle, points) ;
- }
- /*** workaround ???? ***/
- vsf_color(p->handle, BLACK); vsl_color(p->handle, BLACK) ;
-
- /*** clipping = off ***/
- vs_clip(p->handle, FALSE, clipping_points) ;
- return(parmblk->pb_currstate) ;
- }
-
- /****************************************/
- static int cdecl note(PARMBLK *parmblk) /*
- *****************************************/
- {
- PARAMS *p = (PARAMS *)parmblk->pb_parm ;
- int points[4], clipping_points[4] ;
- int type = 0 ;
-
- /*** calculate border points for clipping rectangle, clipping = on ***/
- clipping_points[0] = parmblk->pb_xc ;
- clipping_points[1] = parmblk->pb_yc ;
- clipping_points[2] = clipping_points[0] + parmblk->pb_wc - 1 ;
- clipping_points[3] = clipping_points[1] + parmblk->pb_hc - 1 ;
- vs_clip(p->handle, TRUE, clipping_points) ;
-
- /*** fit points to userdef object size and location ***/
- points[0] = parmblk->pb_x ;
- points[1] = parmblk->pb_y + (parmblk->pb_h >> 2) ;
- points[2] = parmblk->pb_x + parmblk->pb_w - 1 ;
- points[3] = parmblk->pb_y + parmblk->pb_h - 1 - (parmblk->pb_h >> 2) ;
-
- /*** set drawing styles ***/
- vsf_perimeter(p->handle, 1) ; /* with perimeter */
- vsl_type(p->handle, SOLID) ;
-
- /*** draw corresponding note ***/
- switch(parmblk->pb_obj)
- {
- case HEAD_0: break ;
- case HEAD_1: type = HEAD_LINE ; break ;
- case HEAD_2: type = HEAD_TRI ; break ;
- case BODY_0: break ;
- case BODY_1: type = BODY_RECT ; break ;
- case BODY_2: type = BODY_ELLIP ; break ;
- case TAIL_0: break ;
- case TAIL_1: type = TAIL_LINE ; break ;
- case TAIL_2: type = TAIL_TRI ; break ;
- }
- if (p->front) type |= BODY_FRONT ;
- draw_note(p->handle, points, type, p->style[p->index], p->color[p->index]) ;
-
- /*** workaround ???? ***/
- vsf_color(p->handle, BLACK); vsl_color(p->handle, BLACK) ;
-
- /*** clipping = off ***/
- vs_clip(p->handle, FALSE, clipping_points) ;
- return(parmblk->pb_currstate) ;
- }
-
-
- static int /* return: 0 if success, -1 if file not found or wrong format */
- /************/
- load_params /*
- *************/
- (
- Awindow *wi, /* input: parameters window */
- char *path /* input: path (including file name) */
- )
- {
- PARAMS *p = wi->user ;
- Awindow *font_wi = p->font_wi ;
- long filesize ;
- PARAMS_FILE *pf ;
- char *text ;
- int i ;
-
- /*** load the parameter file into RAM ***/
- if ( load_file(path, &filesize, (void *)&pf) == file_loaded )
- {
- if ( filesize == sizeof *pf )
- {
- /*** copy file data into object data ***/
- text = wi->work[TITLE].ob_spec.tedinfo->te_ptext ;
- *text = '\0' ;
- strncat(text, pf->title, TITLE_FIELD_LENGTH) ;
- if (pf->bars_per_system > 99) pf->bars_per_system = 99 ;
- itoa(pf->bars_per_system, wi->work[BARS_PER_SYSTEM].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->bar_length > 99) pf->bar_length = 99 ;
- itoa(pf->bar_length, wi->work[BAR_LENGTH].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->sub_bars > 9) pf->sub_bars = 9 ;
- itoa(pf->sub_bars, wi->work[SUB_BARS].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->left_border > 99) pf->left_border = 99 ;
- itoa(pf->left_border, wi->work[LEFT_BORDER].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->right_border > 99) pf->right_border = 99 ;
- itoa(pf->right_border, wi->work[RIGHT_BORDER].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->upper_border > 99) pf->upper_border = 99 ;
- itoa(pf->upper_border, wi->work[UPPER_BORDER].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->lower_border > 99) pf->lower_border = 99 ;
- itoa(pf->lower_border, wi->work[LOWER_BORDER].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->system_distance > 99) pf->system_distance = 99 ;
- itoa(pf->system_distance, wi->work[SYSTEM_DISTANCE].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->track_distance > 99) pf->track_distance = 99 ;
- itoa(pf->track_distance, wi->work[TRACK_DISTANCE].ob_spec.tedinfo->te_ptext, 10) ;
- itoa(pf->note_distance, wi->work[NOTE_DISTANCE].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->hor_lines > 9) pf->hor_lines = 9 ;
- itoa(pf->hor_lines, wi->work[HOR_LINES].ob_spec.tedinfo->te_ptext, 10) ;
- for (i = 0 ; i < 12 ; i++)
- {
- p->color[i] = pf->color[i] ;
- p->style[i] = pf->style[i] ;
- p->back_color[i] = pf->back_color[i] ;
- p->back_style[i] = pf->back_style[i] ;
- }
- /*** deselect radio buttons ***/
- wi->work[RADIO_TAIL_0].ob_state &= ~SELECTED ;
- wi->work[RADIO_TAIL_1].ob_state &= ~SELECTED ;
- wi->work[RADIO_TAIL_2].ob_state &= ~SELECTED ;
- wi->work[RADIO_HEAD_0].ob_state &= ~SELECTED ;
- wi->work[RADIO_HEAD_1].ob_state &= ~SELECTED ;
- wi->work[RADIO_HEAD_2].ob_state &= ~SELECTED ;
- wi->work[RADIO_BODY_0].ob_state &= ~SELECTED ;
- wi->work[RADIO_BODY_1].ob_state &= ~SELECTED ;
- wi->work[RADIO_BODY_2].ob_state &= ~SELECTED ;
-
- /*** determine radio button for note body ***/
- if ( pf->type & BODY_ELLIP ) wi->work[RADIO_BODY_2].ob_state |= SELECTED ;
- else if ( pf->type & BODY_RECT ) wi->work[RADIO_BODY_1].ob_state |= SELECTED ;
- else wi->work[RADIO_BODY_0].ob_state |= SELECTED ;
- if ( pf->type & BODY_FRONT )
- {
- wi->work[FRONT].ob_state |= SELECTED ;
- wi->work[BACK].ob_state &= ~SELECTED ;
- p->front = TRUE ;
- }
- else
- {
- wi->work[BACK].ob_state |= SELECTED ;
- wi->work[FRONT].ob_state &= ~SELECTED ;
- p->front = FALSE ;
- }
-
- /*** determine radio button for note head ***/
- if ( pf->type & HEAD_TRI ) wi->work[RADIO_HEAD_2].ob_state |= SELECTED ;
- else if ( pf->type & HEAD_LINE ) wi->work[RADIO_HEAD_1].ob_state |= SELECTED ;
- else wi->work[RADIO_HEAD_0].ob_state |= SELECTED ;
-
- /*** determine radio button for note tail ***/
- if ( pf->type & TAIL_TRI ) wi->work[RADIO_TAIL_2].ob_state |= SELECTED ;
- else if ( pf->type & TAIL_LINE ) wi->work[RADIO_TAIL_1].ob_state |= SELECTED ;
- else wi->work[RADIO_TAIL_0].ob_state |= SELECTED ;
-
- /*** height and dynamic ***/
- if (pf->height > 9) pf->height = 9 ;
- itoa(pf->height, wi->work[AVERAGE_HEIGHT].ob_spec.tedinfo->te_ptext, 10) ;
- if (pf->dynamic > 9) pf->dynamic = 9 ;
- itoa(pf->dynamic, wi->work[DYNAMIC].ob_spec.tedinfo->te_ptext, 10) ;
-
- /*** fonts and headline style ***/
- for ( i = 0 ; i < p->number_fonts ; i++ )
- {
- if ( pf->font_id == (p->font_info + i)->font_id )
- {
- p->font_id = pf->font_id ;
- if (font_wi != NULL)
- font_wi->work[FONT_INDEX[i]].ob_state |= SELECTED ;
- }
- else
- if (font_wi != NULL)
- font_wi->work[FONT_INDEX[i]].ob_state &= ~SELECTED ;
- }
- p->effect = pf->effect ;
- if (p->effect & BOLD) wi->menu[_BOLD] .ob_state |= CHECKED ;
- else wi->menu[_BOLD] .ob_state &= ~CHECKED ;
- if (p->effect & LIGHT) wi->menu[_LIGHT] .ob_state |= CHECKED ;
- else wi->menu[_LIGHT] .ob_state &= ~CHECKED ;
- if (p->effect & ITALIC) wi->menu[_ITALIC] .ob_state |= CHECKED ;
- else wi->menu[_ITALIC] .ob_state &= ~CHECKED ;
- if (p->effect & UNDERLINED) wi->menu[_UNDERLINED].ob_state |= CHECKED ;
- else wi->menu[_UNDERLINED].ob_state &= ~CHECKED ;
- if (p->effect & OUTLINED) wi->menu[_OUTLINED] .ob_state |= CHECKED ;
- else wi->menu[_OUTLINED] .ob_state &= ~CHECKED ;
-
- /*** notation mode ***/
- wi->menu[BEYREUTHER].ob_state &= ~CHECKED ;
- wi->menu[RIEDER].ob_state &= ~CHECKED ;
- wi->menu[MIX].ob_state &= ~CHECKED ;
- switch (pf->mode)
- {
- case Beyreuther: wi->menu[BEYREUTHER].ob_state |= CHECKED ; break ;
- case Mix: wi->menu[MIX].ob_state |= CHECKED ; break ;
- default: wi->menu[RIEDER].ob_state |= CHECKED ;
- }
- }
- else
- {
-
- /*** file verion is not 2.x ***/
- alert_str(WRONG_FORMAT, path) ;
-
- /*** free RAM file ***/
- unload_file(pf) ;
- return -1 ; /* no success */
- }
- /*** free RAM file ***/
- unload_file(pf) ;
-
- /*** refresh objects ***/
- Awi_obchange(wi, 0, -1) ;
- if (p->font_wi != NULL) Awi_obchange(p->font_wi, 0, -1) ;
-
- /*** actualize protocol window ***/
- Awi_sendall(REDRAW, wi) ;
- return 0 ; /* success */
- }
- else return -1 ; /* no success */
- }
-
- /************************/
- static void save_params /*
- *************************/
- (
- Awindow *wi, /* input: parameters window */
- char *path /* input: path (including file name) */
- )
- {
- PARAMS *p = wi->user ;
- PARAMS_FILE pf ;
- int handle, i ;
-
- /*** try to open path ***/
- handle = Fopen(path, FO_WRITE) ;
- if ( handle < 0 )
- {
- /*** try to create ?.PAR ***/
- handle = Fcreate(path, 0 /* ordinary file */) ;
- if ( handle < 0 )
- {
- alert_str(NOT_CREATED, path) ;
- return ;
- }
- }
- /*** prepare structure for saving parameters ***/
- strcpy(pf.title, wi->work[TITLE].ob_spec.tedinfo->te_ptext) ;
- pf.bars_per_system = atoi(wi->work[BARS_PER_SYSTEM].ob_spec.tedinfo->te_ptext) ;
- pf.bar_length = atoi(wi->work[BAR_LENGTH].ob_spec.tedinfo->te_ptext) ;
- pf.sub_bars = atoi(wi->work[SUB_BARS].ob_spec.tedinfo->te_ptext) ;
- pf.left_border = atoi(wi->work[LEFT_BORDER].ob_spec.tedinfo->te_ptext) ;
- pf.right_border = atoi(wi->work[RIGHT_BORDER].ob_spec.tedinfo->te_ptext) ;
- pf.upper_border = atoi(wi->work[UPPER_BORDER].ob_spec.tedinfo->te_ptext) ;
- pf.lower_border = atoi(wi->work[LOWER_BORDER].ob_spec.tedinfo->te_ptext) ;
- pf.system_distance = atoi(wi->work[SYSTEM_DISTANCE].ob_spec.tedinfo->te_ptext) ;
- pf.track_distance = atoi(wi->work[TRACK_DISTANCE].ob_spec.tedinfo->te_ptext) ;
- pf.note_distance = atoi(wi->work[NOTE_DISTANCE].ob_spec.tedinfo->te_ptext) ;
- pf.hor_lines = atoi(wi->work[HOR_LINES].ob_spec.tedinfo->te_ptext) ;
- for (i = 0 ; i < 12 ; i++)
- {
- pf.color[i] = p->color[i] ;
- pf.style[i] = p->style[i] ;
- pf.back_color[i] = p->back_color[i] ;
- pf.back_style[i] = p->back_style[i] ;
- }
- pf.type = 0 ;
- if (wi->work[RADIO_HEAD_1].ob_state & SELECTED) pf.type |= HEAD_LINE ;
- if (wi->work[RADIO_HEAD_2].ob_state & SELECTED) pf.type |= HEAD_TRI ;
- if (wi->work[RADIO_BODY_1].ob_state & SELECTED) pf.type |= BODY_RECT ;
- if (wi->work[RADIO_BODY_2].ob_state & SELECTED) pf.type |= BODY_ELLIP ;
- if (wi->work[FRONT].ob_state & SELECTED) pf.type |= BODY_FRONT ;
- if (wi->work[RADIO_TAIL_1].ob_state & SELECTED) pf.type |= TAIL_LINE ;
- if (wi->work[RADIO_TAIL_2].ob_state & SELECTED) pf.type |= TAIL_TRI ;
- pf.height = atoi(wi->work[AVERAGE_HEIGHT].ob_spec.tedinfo->te_ptext) ;
- pf.dynamic = atoi(wi->work[DYNAMIC].ob_spec.tedinfo->te_ptext) ;
- pf.font_id = p->font_id ;
- pf.effect = p->effect ;
- if (wi->menu[BEYREUTHER].ob_state & CHECKED) pf.mode = Beyreuther ;
- else if (wi->menu[MIX].ob_state & CHECKED) pf.mode = Mix ;
- else pf.mode = Rieder ;
-
- /*** save structure ***/
- if ( Fwrite(handle, sizeof pf, &pf) < 0 )
- alert_str(WRITE_ERROR, path) ;
-
- /*** close file ***/
- Fclose(handle) ;
- }
-
- /***********************/
- static void bold(void) /*
- ************************/
- {
- /*** invert bits ***/
- ev_object[_BOLD].ob_state ^= CHECKED ;
- ((PARAMS *)(ev_window->user))->effect ^= BOLD ;
-
- /*** actualize protocol window ***/
- Awi_sendall(REDRAW, ev_window) ;
- }
-
- /************************/
- static void light(void) /*
- *************************/
- {
- ev_object[_LIGHT].ob_state ^= CHECKED ;
- ((PARAMS *)(ev_window->user))->effect ^= LIGHT ;
- Awi_sendall(REDRAW, ev_window) ;
- }
-
- /*************************/
- static void italic(void) /*
- **************************/
- {
- ev_object[_ITALIC].ob_state ^= CHECKED ;
- ((PARAMS *)(ev_window->user))->effect ^= ITALIC ;
- Awi_sendall(REDRAW, ev_window) ;
- }
-
- /*****************************/
- static void underlined(void) /*
- ******************************/
- {
- ev_object[_UNDERLINED].ob_state ^= CHECKED ;
- ((PARAMS *)(ev_window->user))->effect ^= UNDERLINED ;
- Awi_sendall(REDRAW, ev_window) ;
- }
-
- /***************************/
- static void outlined(void) /*
- ****************************/
- {
- ev_object[_OUTLINED].ob_state ^= CHECKED ;
- ((PARAMS *)(ev_window->user))->effect ^= HOLLOW ;
- Awi_sendall(REDRAW, ev_window) ;
- }
-
-
- /********************/
- static void uncheck /*
- *********************/
- (
- OBJECT *obj /* input: parent object */
- )
- {
- obj[RIEDER].ob_state &= ~CHECKED ;
- obj[MIX].ob_state &= ~CHECKED ;
- obj[BEYREUTHER].ob_state &= ~CHECKED ;
- }
-
- /*************************/
- static void rieder(void) /*
- **************************/
- {
- uncheck(ev_object) ;
- ev_object[RIEDER].ob_state |= CHECKED ;
-
- /*** actualize protocol window ***/
- Awi_sendall(REDRAW, ev_window) ;
- }
-
- /*****************************/
- static void beyreuther(void) /*
- ******************************/
- {
- uncheck(ev_object) ;
- ev_object[BEYREUTHER].ob_state |= CHECKED ;
- Awi_sendall(REDRAW, ev_window) ;
- }
-
- /**********************/
- static void mix(void) /*
- ***********************/
- {
- uncheck(ev_object) ;
- ev_object[MIX].ob_state |= CHECKED ;
- Awi_sendall(REDRAW, ev_window) ;
- }
-
- /*****************************/
- static void show_fonts(void) /*
- ******************************/
- {
- PARAMS *p = ev_window->user ;
- Awindow *font_wi = p->font_wi ;
- int i ;
- char *text ;
-
- if (font_wi == NULL)
- {
- /*** window must be created ***/
- p->font_wi = font_wi = Awi_create(&FONT_WINDOW) ;
- if (font_wi == NULL) return ;
- font_wi->user = p ;
-
- /*** copy filename ***/
- Ast_delete(font_wi->info) ;
- font_wi->info = Ast_create(ev_window->info) ;
-
- /*** adapt work object to number and names of fonts ***/
- for ( i = 0 ; i < p->number_fonts ; i++ )
- {
- text = font_wi->work[FONT_INDEX[i]].ob_spec.tedinfo->te_ptext ;
- strcpy(text, " ") ;
- strncat(text, (p->font_info + i)->font_name, MAXLEN) ;
-
- /*** select object according to font ID ***/
- if ( p->font_id == (p->font_info + i)->font_id )
- font_wi->work[FONT_INDEX[i]].ob_state |= SELECTED ;
- else font_wi->work[FONT_INDEX[i]].ob_state &= ~SELECTED ;
- }
- font_wi->work[FONT].ob_height = font_wi->work[FONT_0].ob_height * p->number_fonts ;
-
- /*** small window needs less elements ***/
- if (p->number_fonts <= 10) font_wi->wi_kind &= ~(VSLIDE|UPARROW|DNARROW|SIZER|FULLER) ;
- }
- Awi_show(font_wi) ;
- }
-
- /***********************/
- static void font(void) /*
- ************************/
- {
- int i ;
- PARAMS *p = ev_window->user ;
-
- for ( i = 0 ; i < p->number_fonts ; i++ )
- if ( ev_window->work[FONT_INDEX[i]].ob_state & SELECTED )
- p->font_id = (p->font_info + i)->font_id ;
- Awi_sendall( REDRAW, p->params_wi ) ;
- }
-
-
- static int /* return: TRUE if task was treated, FALSE else */
- /********/
- service /*
- *********/
- (
- Awindow *wi, /* input: parameters window */
- int task, /* input: message from ACS or other window */
- void *not_used /* input: not used here */
- )
- {
- switch (task)
- {
- case AS_TERM: Awi_sendall(TERMINATE, wi) ; break ;
- case AS_INFO: A_dialog(&PARAMS_INFO) ; break ;
- default: return FALSE ;
- }
- return TRUE ;
- }
-
- /***********************/
- static void close_font /*
- ************************/
- (
- Awindow *wi /* input: font window */
- )
- { ((PARAMS *)(wi->user))->font_wi = NULL ; }
-
-
- /************************/
- static void color(void) /*
- *************************/
- {
- PARAMS *p = ev_window->user ;
- int number_colors = ncolors, color ;
- Axywh offset ;
-
- Aob_offset(&offset, ev_object, COLOR) ;
- if (number_colors > 16) number_colors = 16 ;
-
- /*** update color ***/
- color = (ev_mmox - offset.x - ev_window->wi_work.x) * number_colors / offset.w ;
- if (p->show == SH_NOTE)
- {
- /*** refresh notes ***/
- p->color[p->index] = color ;
- Awi_obchange(ev_window, TAIL_0, -1) ;
- Awi_obchange(ev_window, TAIL_1, -1) ;
- Awi_obchange(ev_window, TAIL_2, -1) ;
- Awi_obchange(ev_window, BODY_0, -1) ;
- Awi_obchange(ev_window, BODY_1, -1) ;
- Awi_obchange(ev_window, BODY_2, -1) ;
- Awi_obchange(ev_window, HEAD_0, -1) ;
- Awi_obchange(ev_window, HEAD_1, -1) ;
- Awi_obchange(ev_window, HEAD_2, -1) ;
- }
- else
- {
- /*** refresh background user def. ***/
- p->back_color[p->back_index] = color ;
- Awi_obchange(ev_window, BACKGROUND, -1) ;
- }
- if (set_timer(ev_window) == -1) Awi_sendall(REDRAW, ev_window) ;
- }
-
- /**************************/
- static void pattern(void) /*
- ***************************/
- {
- PARAMS *p = ev_window->user ;
- int style ;
-
- /*** update drawing style ***/
- switch (ev_obnr)
- {
- case PATTERN_1: style = 0 ; break ;
- case PATTERN_2: style = 1 ; break ;
- case PATTERN_3: style = 2 ; break ;
- case PATTERN_4: style = 3 ; break ;
- case PATTERN_5: style = 4 ; break ;
- case PATTERN_6: style = 5 ; break ;
- case PATTERN_7: style = 6 ; break ;
- case PATTERN_8: style = 7 ; break ;
- case PATTERN_9: style = 8 ; break ;
- }
- if (p->show == SH_NOTE)
- {
- /*** refresh notes ***/
- p->style[p->index] = style ;
- Awi_obchange(ev_window, TAIL_0, -1) ;
- Awi_obchange(ev_window, TAIL_1, -1) ;
- Awi_obchange(ev_window, TAIL_2, -1) ;
- Awi_obchange(ev_window, BODY_0, -1) ;
- Awi_obchange(ev_window, BODY_1, -1) ;
- Awi_obchange(ev_window, BODY_2, -1) ;
- Awi_obchange(ev_window, HEAD_0, -1) ;
- Awi_obchange(ev_window, HEAD_1, -1) ;
- Awi_obchange(ev_window, HEAD_2, -1) ;
- }
- else
- {
- /*** refresh background user def. ***/
- p->back_style[p->back_index] = style ;
- Awi_obchange(ev_window, BACKGROUND, -1) ;
- }
- if (set_timer(ev_window) == -1) Awi_sendall(REDRAW, ev_window) ;
- }
-
- /*******************************/
- static void radio_button(void) /*
- *
- (except for the front & back *
- buttons) *
- ********************************/
- { Awi_sendall(REDRAW, ev_window) ; }
-
- /*********************************/
- static void radio_button_1(void) /*
- *
- (for the front & back buttons) *
- **********************************/
- {
- PARAMS *p = ev_window->user ;
-
- if (ev_obnr == FRONT) p->front = TRUE ;
- else p->front = FALSE ;
- Awi_obchange(ev_window, TAIL_0, -1) ;
- Awi_obchange(ev_window, TAIL_1, -1) ;
- Awi_obchange(ev_window, TAIL_2, -1) ;
- Awi_obchange(ev_window, BODY_0, -1) ;
- Awi_obchange(ev_window, BODY_1, -1) ;
- Awi_obchange(ev_window, BODY_2, -1) ;
- Awi_obchange(ev_window, HEAD_0, -1) ;
- Awi_obchange(ev_window, HEAD_1, -1) ;
- Awi_obchange(ev_window, HEAD_2, -1) ;
- Awi_sendall(REDRAW, ev_window) ;
- }
-
- /*******************/
- static void save() /*
- ********************/
- { save_params(ev_window, ((PARAMS *)(ev_window->user))->path) ; }
-
- /*******************/
- static void load() /*
- ********************/
- { load_params(ev_window, ((PARAMS *)(ev_window->user))->path) ; }
-
-
- /**********************/
- static void save___() /*
- ***********************/
- {
- char filename[filename_length] ; /* here: a dummy */
-
- switch ( get_file_name(savepathname, savepath, filename, "Save parameter file") )
- {
- case no_file_selected:
- case file_select_error: return ;
- }
- save_params(ev_window, savepathname) ;
- }
-
- /**********************/
- static void load___() /*
- ***********************/
- {
- char filename[filename_length] ; /* here: a dummy */
-
- switch ( get_file_name(loadpathname, loadpath, filename, "Load parameter file") )
- {
- case no_file_selected:
- case file_select_error: return ;
- }
- load_params(ev_window, loadpathname) ;
- }
-
-
- static char *popup = "0|1|2|3|4|5|6|7|8|9|A|B" ;
-
- /*************************/
- static void number(void) /*
- **************************/
- {
- PARAMS *p = ev_window->user ;
- int *index ;
- static char *new_selection, *old_selection ;
-
- if (p->show == SH_NOTE)
- {
- index = &(p->index) ;
- old_selection = popup + (p->index << 1) ;
- }
- else
- {
- index = &(p->back_index) ;
- old_selection = popup + (p->back_index << 1) ;
- }
- new_selection = Ame_strpopup(ev_window, popup, old_selection, 40, -1 , -1) ;
- if (!new_selection) return ;
- switch (*new_selection)
- {
- case '0': *index = 0 ; break ;
- case '1': *index = 1 ; break ;
- case '2': *index = 2 ; break ;
- case '3': *index = 3 ; break ;
- case '4': *index = 4 ; break ;
- case '5': *index = 5 ; break ;
- case '6': *index = 6 ; break ;
- case '7': *index = 7 ; break ;
- case '8': *index = 8 ; break ;
- case '9': *index = 9 ; break ;
- case 'A': *index = 10 ; break ;
- case 'B': *index = 11 ; break ;
- } ;
- Awi_obchange(ev_window, NOTE_CARRIER_1, -1) ;
- Awi_obchange(ev_window, NOTE_CARRIER_2, -1) ;
- Awi_obchange(ev_window, NOTE_CARRIER_3, -1) ;
- Awi_obchange(ev_window, BACKGROUND, -1) ;
- ev_object[NUMBER].ob_spec.tedinfo->te_ptext[0] = popup[(*index)<<1] ;
- Awi_obchange(ev_window, NUMBER, -1) ;
- }
-
- /****************************/
- static void show_note(void) /*
- *****************************/
- {
- PARAMS *p = ev_window->user ;
-
- p->show = SH_NOTE ;
- ev_window->work[NOTE_CARRIER_1].ob_flags &= ~HIDETREE ;
- ev_window->work[NOTE_CARRIER_2].ob_flags &= ~HIDETREE ;
- ev_window->work[NOTE_CARRIER_3].ob_flags &= ~HIDETREE ;
- ev_window->work[FRONT_BACK_CARRIER].ob_flags &= ~HIDETREE ;
- Awi_obchange(ev_window, STYLE_CARRIER, -1) ;
- }
-
- /**********************************/
- static void show_background(void) /*
- ***********************************/
- {
- PARAMS *p = ev_window->user ;
-
- p->show = SH_BACKGROUND ;
- ev_window->work[NOTE_CARRIER_1].ob_flags |= HIDETREE ;
- ev_window->work[NOTE_CARRIER_2].ob_flags |= HIDETREE ;
- ev_window->work[NOTE_CARRIER_3].ob_flags |= HIDETREE ;
- ev_window->work[FRONT_BACK_CARRIER].ob_flags |= HIDETREE ;
- Awi_obchange(ev_window, STYLE_CARRIER, -1) ;
- }
-
-
- /******************************************************************
- *
- * PUBLISHED INTERFACE
- *
- ******************************************************************/
-
- /***********************/
- void PARAMS_destructor /*
- ************************/
- (
- Awindow *params_wi /* input: parameters window to destroy */
- )
- {
- PARAMS *p ;
-
- if (params_wi)
- {
- p = params_wi->user ;
- if (p)
- {
- if (p->font_wi)
- {
- memory_symptom = "PaDstr font_wi" ;
- Awi_delete( p->font_wi ) ;
- }
- memory_symptom = "PaDstr p" ;
- My_free(p) ;
- }
- memory_symptom = "PaDstr params_wi" ;
- Awi_delete(params_wi) ;
- }
- }
-
- Awindow * /* return: NULL if no success, parameters window else */
- /*******************/
- PARAMS_constructor /*
- ********************/
- (
- PARAMS_INIT *params_init /* input: init values */
- )
- {
- Awindow *params_wi ;
- PARAMS *p ;
- char *last_point ;
- int i ;
-
- /*** enter filename into icon text and info line ***/
- PARAMS_WINDOW.iconblk = params_init->icon ;
- PARAMS_WINDOW.iconblk->monoblk.ib_ptext = params_init->filename ;
- PARAMS_WINDOW.info = params_init->filename ;
-
- /*** create the paramters window ***/
- params_wi = Awi_create(&PARAMS_WINDOW) ;
- if (!params_wi) return NULL ;
-
- /*** allocate params structure and initialize ***/
- params_wi->user = p = My_alloc(sizeof *p) ;
- if (!p) { PARAMS_destructor(params_wi) ; return NULL ; }
- p->handle = params_init->handle ;
- p->show = SH_NOTE ;
- for (i = 0 ; i < 12 ; i++)
- {
- p->style[i] = IP_SOLID ; p->color[i] = BLACK ;
- p->back_style[i] = IP_1PATT ; p->back_color[i] = BLACK ;
- }
- p->index = p->back_index = 0 ;
- p->front = FALSE ;
- p->effect = NORMAL ;
- p->params_wi = params_wi ;
- p->font_wi = NULL ;
- p->font_info = params_init->font_info ;
- p->number_fonts = params_init->number_fonts ;
- strcpy(p->path, params_init->path) ;
- strcpy(loadpath, params_init->path) ;
- *( strrchr(p->path, '\\') + 1 ) = '\0' ;
- *( strrchr(loadpath, '\\') + 1 ) = '\0' ;
- strcat(p->path, params_init->filename) ;
- strcat(loadpath, "*.PAR") ;
- strcpy(savepath, loadpath) ;
-
- /*** extension ".PAR" for parameters filename ***/
- last_point = strrchr(p->path, '.') ;
- if (last_point != NULL) *last_point = '\0' ;
- strcat(p->path, ".PAR") ;
-
- /*** default path name (if no own parameters file exists for the MIDI file) ***/
- strcpy(default_path, apppath) ;
- *( strrchr(default_path, '\\') + 1 ) = '\0' ;
- strcat(default_path, "MIDI_PRT.PAR") ;
-
- /*** load parameters file ***/
- if ( load_params(params_wi, p->path) < 0 ) load_params(params_wi, default_path) ;
-
- /*** if headline still empty: enter filename into headline ***/
- if ( *(params_wi->work[TITLE].ob_spec.tedinfo->te_ptext) == '\0' )
- strncat(params_wi->work[TITLE].ob_spec.tedinfo->te_ptext, params_init->filename, TITLE_FIELD_LENGTH) ;
-
- /*** userdef drawing routines called by AES need access to PARAMS ***/
- params_wi->work[COLOR].ob_spec.userblk->ub_parm =
- params_wi->work[BACKGROUND].ob_spec.userblk->ub_parm =
- params_wi->work[TAIL_0].ob_spec.userblk->ub_parm =
- params_wi->work[TAIL_1].ob_spec.userblk->ub_parm =
- params_wi->work[TAIL_2].ob_spec.userblk->ub_parm =
- params_wi->work[HEAD_0].ob_spec.userblk->ub_parm =
- params_wi->work[HEAD_1].ob_spec.userblk->ub_parm =
- params_wi->work[HEAD_2].ob_spec.userblk->ub_parm =
- params_wi->work[BODY_0].ob_spec.userblk->ub_parm =
- params_wi->work[BODY_1].ob_spec.userblk->ub_parm =
- params_wi->work[BODY_2].ob_spec.userblk->ub_parm = (long)p ;
-
- /*** return success message ***/
- return params_wi ;
- }
-
-
- char *get_title(Awindow *wi)
- { return wi->work[TITLE].ob_spec.tedinfo->te_ptext ; }
-
- int get_bars_per_system(Awindow *wi)
- { return atoi(wi->work[BARS_PER_SYSTEM].ob_spec.tedinfo->te_ptext) ; }
-
- int get_system_length(Awindow *wi)
- { return atoi(wi->work[BAR_LENGTH].ob_spec.tedinfo->te_ptext) *
- atoi(wi->work[BARS_PER_SYSTEM].ob_spec.tedinfo->te_ptext); }
-
- char get_bar_divider(Awindow *wi)
- { return atoi(wi->work[SUB_BARS].ob_spec.tedinfo->te_ptext) + 1 ; }
-
- int get_left_border(Awindow *wi)
- { return atoi(wi->work[LEFT_BORDER].ob_spec.tedinfo->te_ptext) ; }
-
- int get_right_border(Awindow *wi)
- { return atoi(wi->work[RIGHT_BORDER].ob_spec.tedinfo->te_ptext) ; }
-
- int get_upper_border(Awindow *wi)
- { return atoi(wi->work[UPPER_BORDER].ob_spec.tedinfo->te_ptext) ; }
-
- int get_lower_border(Awindow *wi)
- { return atoi(wi->work[LOWER_BORDER].ob_spec.tedinfo->te_ptext) ; }
-
- int get_system_distance(Awindow *wi)
- { return atoi(wi->work[SYSTEM_DISTANCE].ob_spec.tedinfo->te_ptext) ; }
-
- int get_track_distance(Awindow *wi)
- { return atoi(wi->work[TRACK_DISTANCE].ob_spec.tedinfo->te_ptext) ; }
-
- int get_note_distance(Awindow *wi)
- { return atoi(wi->work[NOTE_DISTANCE].ob_spec.tedinfo->te_ptext) ; }
-
- int get_hor_lines(Awindow *wi)
- { return atoi(wi->work[HOR_LINES].ob_spec.tedinfo->te_ptext) ; }
-
- /**********************/
- void get_style_params /*
- ***********************/
- (
- Awindow *wi, /* input: parameters window */
- int style[12], /* output: 12 note styles */
- int color[12], /* output: 12 note colors */
- int *type, /* output: note type */
- int *height, /* output: note height */
- int *dynamic, /* output: note dynamic */
- int back_style[12], /* output: 12 background styles */
- int back_color[12] /* output: 12 background colors */
- )
- {
- PARAMS *p = wi->user ;
- int i ;
-
- /*** determine note type ***/
- *type = 0 ;
- if (wi->work[RADIO_HEAD_1].ob_state & SELECTED) *type |= HEAD_LINE ;
- if (wi->work[RADIO_HEAD_2].ob_state & SELECTED) *type |= HEAD_TRI ;
- if (wi->work[RADIO_BODY_1].ob_state & SELECTED) *type |= BODY_RECT ;
- if (wi->work[RADIO_BODY_2].ob_state & SELECTED) *type |= BODY_ELLIP ;
- if (wi->work[FRONT].ob_state & SELECTED) *type |= BODY_FRONT ;
- if (wi->work[RADIO_TAIL_1].ob_state & SELECTED) *type |= TAIL_LINE ;
- if (wi->work[RADIO_TAIL_2].ob_state & SELECTED) *type |= TAIL_TRI ;
-
- /*** rest ***/
- for (i = 0 ; i < 12 ; i++)
- {
- color[i] = p->color[i] ;
- style[i] = p->style[i] ;
- back_color[i] = p->back_color[i] ;
- back_style[i] = p->back_style[i] ;
- }
- *height = atoi(wi->work[AVERAGE_HEIGHT].ob_spec.tedinfo->te_ptext) ;
- *dynamic = atoi(wi->work[DYNAMIC].ob_spec.tedinfo->te_ptext) ;
- }
-
-
- int /* return: VDI text effects for headline */
- /*****************/
- get_text_effects /*
- ******************/
- (
- Awindow *wi /* input: parameters window */
- )
- { return ((PARAMS *)(wi->user))->effect ; }
-
- int /* return: GDOS font ID */
- /************/
- get_font_id /*
- *************/
- (
- Awindow *wi /* input: parameters window */
- )
- { return ((PARAMS *)(wi->user))->font_id ; }
-
- int /* return: notation mode */
- /*********/
- get_mode /*
- **********/
- (
- Awindow *wi /* input: parameters window */
- )
- {
- if (wi->menu[BEYREUTHER].ob_state & CHECKED) return Beyreuther ;
- if (wi->menu[MIX].ob_state & CHECKED) return Mix ;
- return Rieder ;
- }
-